package com.soFun.service;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * 应用程序信息服务
 */
@Service
public class AppInfoService {

    @Value("${spring.application.name}")
    private String applicationName;

    @Value("${server.port}")
    private int serverPort;

    /**
     * 获取应用程序信息
     * @return 包含应用程序信息的Map
     */
    public Map<String, Object> getAppInfo() {
        Map<String, Object> info = new HashMap<>();
        info.put("name", applicationName);
        info.put("port", serverPort);
        info.put("javaVersion", System.getProperty("java.version"));
        info.put("startTime", System.currentTimeMillis());
        info.put("environment", getEnvironmentInfo());
        return info;
    }

    /**
     * 获取环境信息
     * @return 包含环境信息的Map
     */
    private Map<String, String> getEnvironmentInfo() {
        Map<String, String> env = new HashMap<>();
        env.put("os", System.getProperty("os.name"));
        env.put("osVersion", System.getProperty("os.version"));
        env.put("userDir", System.getProperty("user.dir"));
        return env;
    }
} 